import pymysql


class My_mysql:
    def __init__(self):
        self.db = None

    def get_mysql(self, **args):
        self.db = pymysql.connect(**args)

    def select_sql(self, sql, params=None):
        cursor = self.db.cursor()
        cursor.execute(sql, params)
        data = cursor.fetchall()
        cursor.close()
        return data

    def update_sql(self, sql, params=None):
        cursor = self.db.cursor()
        cursor.execute(sql, params)
        cursor.fetchall()
        self.db.commit()
        cursor.close()

    def close_mysql(self):
        self.db.close()
